define(["jquery","bbcare"],function($,$bb){
	var wechatCode = {};
	var URL = $bb.baseUrl("followapp");

	/**
	 * 请求微信二维码成功后的回调函数
	 */ 
	var ajaxWechatCodeCallBack = function(data){
		var h = '<img alt="'+ data.relationName +'" src="'+ data.qrcodeUrl +'">';
		$(".wechatCode-img").html(h);
	} 

	/**
	 * 请求微信二维码
	 */
	var ajaxWechatCode = function(callback){
		$bb.ajax({
            url: URL + "ctrl/projectManage/qryWechatQrCode",
            success: function (data) {
                if(data.success){
                    callback(data.data);
                }else{
                    $bb.toastShow(data.msg ? data.msg : "请求微信二维码出错！");
                }
            }
        });
	} 

	wechatCode.init = function(){
		var h = $("#content-main").height();
		$(".wechatCode").css({"height":h});
		if( h-100 < 500 ) $(".wechatCode-img").css({"height":h-100,"width":h-100});
		ajaxWechatCode(ajaxWechatCodeCallBack);
	}

	return wechatCode;
});